/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import control.DoanhThuController;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import model.DoanhThu;

/**
 *
 * @author Dom
 */
public class frmDoanhThu extends javax.swing.JFrame {

    /**
     * Creates new form frmDoanhThu
     */
    public frmDoanhThu() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tbDoanhThu = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        txtSoLuotThanhToan = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtTongDoanhThu = new javax.swing.JTextField();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLabel1 = new javax.swing.JLabel();
        cbChonNam = new javax.swing.JCheckBox();
        cbNam = new javax.swing.JComboBox();
        cbThang = new javax.swing.JComboBox();
        rbThang = new javax.swing.JRadioButton();
        rbQuy = new javax.swing.JRadioButton();
        btnXoaKQ = new javax.swing.JButton();
        btnXemKQ = new javax.swing.JButton();
        cbQuy = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        tbDoanhThu.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Ngày giờ giao dịch", "Biển số xe", "Nhân viên giao dịch", "Số tiền (x1000VND)"
            }
        ));
        jScrollPane1.setViewportView(tbDoanhThu);

        jLabel3.setText("Tổng số lượt thanh toán");

        jLabel4.setText("Tổng doanh thu");

        jLayeredPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel1.setText("Năm");
        jLabel1.setBounds(10, 100, 30, 14);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        cbChonNam.setBounds(150, 100, 21, 21);
        jLayeredPane1.add(cbChonNam, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cbNam.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2012", "2013", "2014", "2015", "2016" }));
        cbNam.setBounds(50, 100, 72, 20);
        jLayeredPane1.add(cbNam, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cbThang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12" }));
        cbThang.setBounds(460, 100, 99, 20);
        jLayeredPane1.add(cbThang, javax.swing.JLayeredPane.DEFAULT_LAYER);

        rbThang.setText("Tháng");
        rbThang.setBounds(380, 100, 70, 23);
        jLayeredPane1.add(rbThang, javax.swing.JLayeredPane.DEFAULT_LAYER);

        rbQuy.setText("Quý");
        rbQuy.setBounds(190, 100, 45, 23);
        jLayeredPane1.add(rbQuy, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btnXoaKQ.setText("Xóa KQ");
        btnXoaKQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXoaKQActionPerformed(evt);
            }
        });
        btnXoaKQ.setBounds(680, 90, 80, 40);
        jLayeredPane1.add(btnXoaKQ, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btnXemKQ.setText("Xem KQ");
        btnXemKQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXemKQActionPerformed(evt);
            }
        });
        btnXemKQ.setBounds(580, 90, 90, 40);
        jLayeredPane1.add(btnXemKQ, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cbQuy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Quý I", "Quý II", "Quý III", "Quý IV" }));
        cbQuy.setBounds(250, 100, 117, 20);
        jLayeredPane1.add(cbQuy, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 20)); // NOI18N
        jLabel2.setText("BÁO CÁO DOANH THU");
        jLabel2.setBounds(300, 30, 230, 30);
        jLayeredPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setText("lượt");

        jLabel6.setText(".000VND");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 788, Short.MAX_VALUE)
                        .addComponent(jLayeredPane1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(txtSoLuotThanhToan, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(69, 69, 69)
                        .addComponent(jLabel4)
                        .addGap(33, 33, 33)
                        .addComponent(txtTongDoanhThu, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6)))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(txtSoLuotThanhToan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel4)
                        .addComponent(txtTongDoanhThu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel5))
                    .addComponent(jLabel6))
                .addGap(23, 23, 23))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //nút xem kết quả doanh thu
    private void btnXemKQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXemKQActionPerformed
        // TODO add your handling code here:
        DoanhThu dt = new DoanhThu();
        
       JOptionPane.showMessageDialog(this, "Tính năng đang hoàn thiện!");
       
       dt.setNam(Integer.parseInt(cbNam.getModel().getSelectedItem().toString()));

            if (cbChonNam.isSelected() == true)
            {
                if (rbQuy.isSelected() == true)
                    dt.setQuy(cbQuy.getSelectedIndex() + 1);
                else
                    dt.setThang(cbThang.getSelectedIndex() + 1);
            }
            
        try {
            DoanhThuController.LayBang(tbDoanhThu, dt);
        } catch (SQLException ex) {
            Logger.getLogger(frmDoanhThu.class.getName()).log(Level.SEVERE, null, ex);
        }

            
            //txtSoLuotThanhToan.setText(null) = TongLuot.ToString();
            //txtTongTien.Text = TongTien.ToString();
        
        

    }//GEN-LAST:event_btnXemKQActionPerformed

    //xóa kết quả doanh thu
    private void btnXoaKQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoaKQActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_btnXoaKQActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmDoanhThu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmDoanhThu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmDoanhThu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmDoanhThu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmDoanhThu().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnXemKQ;
    private javax.swing.JButton btnXoaKQ;
    private javax.swing.JCheckBox cbChonNam;
    private javax.swing.JComboBox cbNam;
    private javax.swing.JComboBox cbQuy;
    private javax.swing.JComboBox cbThang;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JRadioButton rbQuy;
    private javax.swing.JRadioButton rbThang;
    private javax.swing.JTable tbDoanhThu;
    private javax.swing.JTextField txtSoLuotThanhToan;
    private javax.swing.JTextField txtTongDoanhThu;
    // End of variables declaration//GEN-END:variables
}
